package com.bao.work;

public class InnerClassTest02 {


    public static void main(String[] args) {
        Apple a=new Apple(5,"绿色");
        Apple b=new Apple(3,"红色");
        CompareAble worker1=new CompareAble() {
            @Override
            public void compare(Apple a, Apple b) {
                CompareAble.super.compare(a, b);
            }
        };
        CompareAble worker2=new CompareAble() {
            @Override
            public void compare(Apple a, Apple b) {
                if("红色".equals(a.getColor())||"red".equals(a.getColor())){
                    System.out.println(a);
                }
                else if("红色".equals(b.getColor())||"red".equals(b.getColor())){
                    System.out.println(b);
                }else {
                    System.out.println("没有红苹果");
                }
            }
        };
        worker1.compare(a,b);
        worker2.compare(a,b);
    }
}
class Apple{
    private int size;
    private String color;

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public Apple(int size, String color) {
        this.size = size;
        this.color = color;
    }

    public Apple() {
    }

    @Override
    public String toString() {
        return "size=" + size + ", color=" + color;
    }
}
interface CompareAble{
    default void compare(Apple a,Apple b){
        if(a.getSize()> b.getSize()){
            System.out.println(a);
        }else {
            System.out.println(b);
        }
    }
}
